<?php $this->layout('layout')?>

<?php $this->start('main')?>

<table class="table table-bordered table-striped tmiddle tcenter">
<thead>
<tr>
<th>ID</th>
<th>帐号</th>
<th>姓名</th>
<th>部门</th>
<th>分组</th>
<th>操作</th>
</tr>
</thead>
<tbody>
<?php foreach ($users as $user): ?>
<tr>
<td><?=$user->id?></td>
<td><?=$user->account?></td>
<td><?=$user->name?>
<?php if ($user->isadmin) {?>
<span class="badge bg-primary">管理员</span>
<?php } ?>

</td>
<td><?=$departments[$user->department]->name?></td>
<td><?=$user->team?></td>
<td>
<div class="btn-group" role="group">
<button type="button" class="btn btn-secondary dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
操作菜单
</button>

<div class="dropdown-menu">
<a class="dropdown-item" href="javascript:ajax('/user/add?id=<?=$user->id?>');">编辑</a>
<a class="dropdown-item" href="javascript:ajax('/user/delform/<?=$user->id?>');">删除</a>
<a class="dropdown-item" href="javascript:ajax('/user/reset_password/<?=$user->id?>');">重置密码</a>
</div>

</div>

</td>
</tr>
<?php endforeach?>
</tbody>
</table>

<?php $this->stop();?>

<?php $this->start('script')?>
<script type="text/javascript">
var users = <?=json_encode($users)?>;
</script>
<?php $this->end()?>
